import request from '@/utils/request.js'

// 质检模版列表
export const templateList = (data) => {
    return request({
        url: '/template/list',
        method: 'post',
        data: data
    })
}

// 新增质检模版
export const newTemplate = (data) => {
    return request({
        url: '/template',
        method: 'post',
        data: data
    })
}

// 模版详情
export const templateDetail = (id) => {
    return request({
        url: '/template/'  + id,
        method: 'get',
    })
}

// 模版详情
export const editTemplate = (data) => {
    return request({
        url: '/template',
        method: 'put',
        data: data
    })
}

// 删除模版
export const delTemplate = (id) => {
    return request({
        url: `/template/${id}`,
        method: 'delete'
    })
}

// 批量删除模版
export const batchDelTemplate = (ids) => {
    return request({
        url: `/template/batchDelete`,
        method: 'delete',
        data: ids
    })
}


// 质检项列表
export const inspectionList = (id) => {
    return request({
        url: `/template/${id}`,
        method: 'get'
    })
}

// 新增质检项
export const newInspection = (data) => {
    return request({
        url: '/inspection',
        method: 'post',
        data: data
    })
}

// 编辑检项
export const editInspection = (data) => {
    return request({
        url: '/inspection',
        method: 'put',
        data: data
    })
}

// 质检项详情
export const inspectionDetail = (data) => {
    return request({
        url: `/inspection/${data.templateId}/${data.id}`,
        method: 'get'
    })
}

// 删除质检项
export const delInspection = (data) => {
    return request({
        url: `/inspection/${data.templateId}/${data.id}`,
        method: 'delete'
    })
}

// 规则列表
export const ruleList = (data) => {
    return request({
        url: `/inspection/list`,
        method: 'post',
        data
    })
}

// 质检点列表
export const pointListByType = (data) => {
    return request({
        url: `/point/getListByType/${data.type}`,
        method: 'get'
    })
}

// 匹配标签数据
export const tagList = (id) => {
    return request({
        url: `/tag/list/${id}`,
        method: 'get'
    })
}

// 新增质检规则
export const newQualityRule = (data) => {
    return request({
        url: `/qualityRule`,
        method: 'post',
        data
    })
}

// 质检规则详情
export const detailQualityRule = (data) => {
    return request({
        url: `/qualityRule/${data.templateId}/${data.qualityRuleId}`,
        method: 'get'
    })
}

// 编辑质检规则
export const editQualityRule = (data) => {
    return request({
        url: `/qualityRule`,
        method: 'put',
        data
    })
}

// 删除质检规则
export const delQualityRule = (data) => {
    return request({
        url: `/qualityRule/${data.templateId}/${data.qualityRuleId}`,
        method: 'delete'
    })
}

// 判断质检规则名称是否重复
export const checkRuleName = (data, type) => {
    return request({
        url: `/qualityRule/checkName/${type}`,
        method: 'post',
        data
    })
}

// 计算模版分数
export const getTemplateScore = (id) => {
    return request({
        url: `/template/getScore/${id}`,
        method: 'get'
    })
}

// 计算规则详情
export const getRuleScore = (data) => {
    return request({
        url: `/inspection/getScore/${data.templateId}/${data.id}`,
        method: 'get'
    })
}

// 批量导出
export const templateExport = (data) => {
    return request({
        url: `/template/export`,
        method: 'post',
        data: data,
        responseType: 'blob'//处理乱码问题，转化为blob类型
    })
}

// 判断质检分数是否符合规则
export const checkScore = (data) => {
    return request({
        url: `/qualityRule/checkScore`,
        method: 'post',
        data
    })
}


// 查询非父非子质检规则列表
export const getNoRelationshipList = (data) => {
    return request({
        url: `/inspection/list/${data.templateId}/${data.inspectionId}/${data.id}`,
        method: 'get'
    })
}

// 新增质检规则父子关系
export const addLevel = (data) => {
    return request({
        url: `/inspection/addLevel`,
        method: 'put',
        data
    })
}

// 解除质检规则父子关系
export const releaseLevel = (data) => {
    return request({
        url: `/inspection/releaseLevel`,
        method: 'put',
        data
    })
}

//查看质检模板是否关联录音结果
export const isAssociationRecord = (id) => {
    return request({
        url:`/template/associationTemplate/${id}`,
        method:'get'
    })
}
